package com.ysstech.etfmanage.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ysstech.etfmanage.feign.entity.Quotation;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 *   ETF台账信息表
 * </p>
 *
 * @author lishuangliang
 * @since 2021-02-10
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("etf_account")
public class Account extends Model<Account> {

    private static final long serialVersionUID = 1L;

    @TableId("ID")
    private String id;
    /**
     * 基金编码
     */
    @TableField("ACCOUNT_ID")
    private String accountId;
    /**
     * 申购日期
     */
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    @TableField("FDATE")
    private LocalDate fdate;
    /**
     * 证券代码
     */
    @TableField("SECURITY_CODE")
    private String securityCode;
    /**
     * 证券名称
     */
    @TableField("SECURITY_NAME")
    private String securityName;
    /**
     * 股东代码
     */
    @TableField("SHAREHOLDER_CODE")
    private String shareholderCode;
    /**
     * 交易席位
     */
    @TableField("DEAL_SEAT")
    private String dealSeat;
    /**
     * 交易单元
     */
    @TableField("DEAL_UNIT")
    private String dealUnit;
    /**
     * 业务类型， 申购，赎回，待买，待卖，必须等
     */
    @TableField("BUSINESS_TYPE")
    private String businessType;
    /**
     * 结算编号
     */
    @TableField("SETTLEMENT_CODE")
    private String settlementCode;
    /**
     * 申赎数量
     */
    @TableField("AMOUNT")
    private BigDecimal amount;
    /**
     * 单位成本
     */
    @TableField("UNIT_COST")
    private BigDecimal unitCost;
    /**
     * 替代金额
     */
    @TableField("REPLACE_MONEY")
    private BigDecimal replaceMoney;
    /**
     * 可退替代金额
     */
    @TableField("REPLACEABLE_MONEY")
    private BigDecimal replaceableMoney;
    /**
     * 剩余数量
     */
    @TableField("SURPLUS_AMOUNT")
    private BigDecimal surplusAmount;
    /**
     * 剩余替代金额
     */
    @TableField("SURPLUS_REPLACE_MONEY")
    private BigDecimal surplusReplaceMoney;
    /**
     * 应退合计（应付替代之和)
     */
    @TableField("TOTAL_PAYABLE_REPLACE_MONEY")
    private BigDecimal totalPayableReplaceMoney;
    /**
     * 清算标志
     */
    @TableField("CLEAR_CODE")
    private String clearCode;
    /**
     * 退款日期
     */
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    @TableField("REFUND_DATE")
    private LocalDate refundDate;
    /**
     * 成交编号
     */
    @TableField("TRANSACTION_NUMBER")
    private String transactionNumber;
    /**
     * 可退替代款估值增值
     */
    @TableField("REPLACEABLE_VALUATION_MONEY")
    private BigDecimal replaceableValuationMoney;
    /**
     * 市场
     */
    @TableField("MARKET")
    private String market;
    /**
     * 汇率
     */
    @TableField("RATE")
    private BigDecimal rate;
    /**
     * ETF类型 1单市场 2跨市场
     */
    @TableField("ETF_TYPE")
    private Integer etfType;

    /**
     * ETF模式 1.股票2.债券。3期货
     */
    @TableField("ETF_MODE")
    private Integer etfMode;
    /**
     * ETF市场
     */
    @TableField("ETF_MARKET")
    private String etfMarket;
    /**
     * 状态
     */
    @TableField("STATUS")
    private Integer status;
    /**
     * 添加时间
     */
    @TableField("ADD_TIME")
    private LocalDateTime addTime;

    /**
     * 添加用户
     */
    @TableField("ADD_USER")
    private String addUser;

    /**
     * 修改时间
     */
    @TableField("EDIT_TIME")
    private LocalDateTime editTime;

    /**
     * 修改用户
     */
    @TableField("EDIT_USER")
    private String editUser;
    /**
     * 删除原因
     */
    @TableField("DELETE_REASON")
    private String deleteReason;
    @Override
    protected Serializable pkVal() {
        return null;
    }

    //查询条件申购日期
    @TableField(exist = false)
    private String purchaseDate;
    //开始日期
    @TableField(exist = false)
    private String startDate;
    //结束日期
    @TableField(exist = false)
    private String endDate;
    //明细汇总
    @TableField(exist = false)
    private String detailSum;
    //补票数据的集合
    @TableField(exist = false)
    private List<AccountFill> listAccountFill = new ArrayList<>();

    //待买总数量
    @TableField(exist = false)
    private BigDecimal sumBuyAmount = BigDecimal.ZERO;
    //待卖总数量
    @TableField(exist = false)
    private BigDecimal sumSellAmount = BigDecimal.ZERO;
    //已补数量
    @TableField(exist = false)
    private BigDecimal makeFillAmount = BigDecimal.ZERO;
    //已补可退替代金额
    @TableField(exist = false)
    private BigDecimal makeFillReplaceableMoney = BigDecimal.ZERO;
    //已补替代金额
    @TableField(exist = false)
    private BigDecimal makeFillReplaceMoney = BigDecimal.ZERO;
    //已补应付替代金额
    @TableField(exist = false)
    private BigDecimal makeFillPayableReplaceMoney = BigDecimal.ZERO;
    //权益数据的集合
    @TableField(exist = false)
    private List<Rights> listRights = new ArrayList<>();
    // 权益数量
    @TableField(exist = false)
    private BigDecimal sumRightsAmount = BigDecimal.ZERO;
    // 权益实际数量
    @TableField(exist = false)
    private BigDecimal sumRightsRealAmount = BigDecimal.ZERO;
    // 权益派息
    @TableField(exist = false)
    private BigDecimal sumRightsDividendMoney = BigDecimal.ZERO;
    // 权益实际派息
    @TableField(exist = false)
    private BigDecimal sumRightsRealDividendMoney = BigDecimal.ZERO;
    // 权益价值
    @TableField(exist = false)
    private BigDecimal sumRightsValueMoney = BigDecimal.ZERO;
    // 权益实际价值
    @TableField(exist = false)
    private BigDecimal sumRightsRealValueMoney = BigDecimal.ZERO;
    //补票数量
    @TableField(exist = false)
    private BigDecimal fillAmount = BigDecimal.ZERO;
    //补票金额
    @TableField(exist = false)
    private BigDecimal fillMoney = BigDecimal.ZERO;
    //篮子的股票数量
    @TableField(exist = false)
    private BigDecimal shareAmount = BigDecimal.ZERO;
    //替代标志
    @TableField(exist = false)
    private Integer replaceCode;
    //证券数量
    @TableField(exist = false)
    private BigDecimal dealAmount = BigDecimal.ZERO;
    //成交金额
    @TableField(exist = false)
    private BigDecimal dealMoney = BigDecimal.ZERO;
    //一级代码证券数量 计算篮子数
    @TableField(exist = false)
    private BigDecimal oneLevelSecurityCodeAmount = BigDecimal.ZERO;
    //篮子里申购的替代金额
    @TableField(exist = false)
    private BigDecimal purchaseReplaceMoney = BigDecimal.ZERO;
    //篮子里赎回的替代金额
    @TableField(exist = false)
    private BigDecimal redeemReplaceMoney = BigDecimal.ZERO;
    // 溢价比例
    @TableField(exist = false)
    private String premiumScale;
    // 折价比例
    @TableField(exist = false)
    private String discountScale;
    //商品期货
    @TableField(exist = false)
    private BigDecimal contractMultiplier = BigDecimal.ZERO; //合约乘数
    //行情价格
    @TableField(exist = false)
    private Quotation quotation;
    /**
     * ETF类型 1单市场 2跨市场
     */
    @TableField(exist = false)
    private String strEtfType;
    /**
     * ETF模式 1.股票2.债券。3期货
     */
    @TableField(exist = false)
    private String strEtfMode;

}
